﻿@using XStudio.Framework.Support.Entity.User
@model List<XStudio.Framework.Support.Entity.Authorize.RoleEntity>
<form name="frmSetAuth" id="frmSetAuth" method="post" action="@Request.Url">
<div style="height: 420px; margin: 0 10px; overflow: auto;">
    @{
        var employees = (IList<EmployeeEntity>)ViewBag.Employees;  
    }
    <div style="margin: 10px 0;">
        <div class="tip-alert-box" id="receiveUse">
            <p>
                <strong>〓 选中员工(@(employees.Count)个)：</strong></p>
            <p>
                @foreach (var item in employees)
                {
                    <span class="btn-user">@item.EmployeeName</span>
                }
            </p>
        </div>
    </div>
    <div class="tbl-wrap">
        <table class="tbl-input" cellspacing="0" style="width: 100%;">
            <colgroup>
                <col style="width: 35%; text-align: left" />
                <col />
            </colgroup>
            <tbody>
                @foreach (var role in Model)
                {
                    <tr>
                        <td>
                            <input type="checkbox" value="@role.UID" @(role.StateCodeID == 9 ? "checked='checked'" : "")    name="role" id="@string.Format("role_{0}", role.UID)" />
                            <label for="@string.Format("role_{0}", role.UID)" >
                                @role.RoleName
                            </label>
                        </td>
                        <td>
                            <span class="btn-info">@role.Remark</span>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>
<p class="op" style="text-align: center; margin-top: 10px;">
    <input type="button" id="btnSave" onclick="SetAuth.Save(this);" class="btn-8" value="设置" />
    <input type="button" value="取消" onclick="SetAuth.Back(this);" class="btn-8" />
</p>
</form>
<script type="text/javascript">
    var SetAuth = {};

    SetAuth.Save = function (e) {
        if (!confirm("确认要设置选中用户的权限吗？"))
            return;

        var frm = $(e).parents("form");
        $.ajax({
            url: $(frm).attr("action"),
            data: $(frm).serialize(),
            type: "Post",
            error: function (request) {
                alert('设置权限出错，请重试！');
            },
            success: function (data) {
                if (data.IsOK) {
                    $.closeWin(e);
                }
                else
                    alert(data.Description);
            }
        });
    }
    SetAuth.Back = function (e) {
        $.closeWin(e);
    }
</script>
